package com.example.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by PC on 2017/10/17.
 */
@RestController
public class DcController {

    @Autowired
    DiscoveryClient discoveryClient;
    @GetMapping("/dc")
    public String dc() throws InterruptedException {
        Thread.sleep(50000L);//todo 为了触发服务降级逻辑，我们可以将服务提供者eureka-client的逻辑加一些延迟
        String services = "Services: " + discoveryClient.getServices();
        System.out.println(services);
        return services;
    }
}
